/*
 * File:    Defines_Peripherals.h
 * Project:	HobbyPilotFirmware (HPF)
 * Author:  Wouter van Verre
 *
 * Created on March 18, 2011, 2:29 PM
 */

#ifndef __DEFINES_PERIPHERALS_H
#define __DEFINES_PERIPHERALS_H

/** Defines **/
#define XRateBuff 	ADCBUF2
#define YRateBuff	ADCBUF1
#define ZRateBuff	ADCBUF3
#define XAccelBuff	ADCBUF5
#define YAccelBuff	ADCBUF4
#define ZAccelBuff 	ADCBUF6	

#define XRateSign	+
#define YRateSign 	-
#define ZRateSign	-
#define XAccelSign	-
#define YAccelSign 	+
#define ZAccelSign 	-

/** Structures **/
typedef struct 
{
	int offset;
	int value;
	int input;
	long accum;
	
} ADChannel;

/** Function Definitions **/
/** Initializers **/
extern void initIO(void);
extern void initUART1(void);
extern void initInterrupts(void);
extern void initOC(void);
extern void initTimer1(void);
extern void initTimer2(void);
extern void initTimer3(void);
extern void initTimer4(void);
extern void initADC(void);

/** Variables **/
extern uint8 Timer1FirstRun;
extern uint8 Timer4FirstRun;

extern int Timer1Counter;
extern int Timer4Counter;

extern ADChannel XRate;
extern ADChannel YRate;
extern ADChannel ZRate;
extern ADChannel XAccel;
extern ADChannel YAccel;
extern ADChannel ZAccel;

extern int16 ADCSampleCount;
#endif
